home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / make / icmake-6.000 / icmake-6 / icmake / rss / fname.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-08  |  1.6 KB  |  101 lines

  1. /*
  2.     #include <stdlib.h>
  3.     #include <stdio.h>
  4.     #include <string.h>
  5.     #include "../icm.h"
  6. */
  7.  
  8. #include "icrssdef.h"
  9.  
  10. static char
  11.     name [_MAX_PATH],
  12.     drive [_MAX_PATH],
  13.     dir [_MAX_PATH],
  14.     fname [_MAX_PATH],
  15.     ext [_MAX_PATH];
  16.  
  17. static void split (char *n)
  18. {
  19.     _splitpath (n, drive, dir, fname, ext);
  20. }
  21.  
  22. static void join ()
  23. {
  24.     _makepath (name, drive, dir, fname, ext);
  25. }
  26.  
  27. char *change_ext (char *n, char *e)
  28. {
  29.     split (n);
  30.     *ext = 0;
  31.     if (e)
  32.         strcpy (ext, e);
  33.     join ();
  34.     return (xstrdup (name));
  35. }
  36.  
  37. char *change_base (char *n, char *b)
  38. {
  39.     split (n);
  40.     *fname = 0;
  41.     if (b)
  42.         strcpy (fname, b);
  43.     join ();
  44.     return (xstrdup (name));
  45. }
  46.  
  47. char *change_path (char *n, char *p)
  48. {
  49.     register char
  50.         *cp;
  51.  
  52.     split (n);
  53.  
  54.     if (p)
  55.     {
  56.         if (DRIVESEP && (cp = strchr (p, DRIVESEP)))
  57.         {
  58.             strcpy (drive, p);
  59.             *(strchr (drive, DRIVESEP) + 1) = '\0';
  60.             strcpy (dir, cp + 1);
  61.         }
  62.         else
  63.             strcpy (dir, p);
  64.     }
  65.  
  66.     join ();
  67.  
  68.     return (xstrdup (name));
  69. }
  70.  
  71. char *get_ext (char *n)
  72. {
  73.     split (n);
  74.     if (*ext == '.')
  75.         return (xstrdup (ext + 1));
  76.     return (xstrdup (ext));
  77. }
  78.  
  79. char *get_base (char *n)
  80. {
  81.     split (n);
  82.     return (xstrdup (fname));
  83. }
  84.  
  85. char *get_path (char *n)
  86. {
  87.     register int
  88.         last;
  89.  
  90.     split (n);
  91.     strcat (drive, dir);
  92.     last = strlen (drive);
  93.     if (last && drive [last - 1] != DIRSEP && drive [last - 1] != DRIVESEP)
  94.     {
  95.         drive[last] = DIRSEP;
  96.         drive[last + 1] = (char)0;
  97.     }
  98.  
  99.     return (xstrdup (drive));
  100. }
  101.